< previous page page_135 next page >

Page 135
Your code can use the button parameter's Key property to determine which button was pressed. For example, consider the following code in the toolbar's ButtonClick event:
Private Sub Toolbar1_ButtonClick(ByVal Button As ComctlLib.Button)

    Select Case Button.Key
        Case "open"
            'Insert open file code here
        Case "save"
            'Insert save file code here
        Case "exit"
            'Insert code to end the program
    End Select

End Sub
The preceding code works great for buttons of type tbrDefault. However, if you have any tbrCheck buttons, you should have your code also check the Value property to see what the state of the button is:
        Case "boldface"
            If Button.value = tbrUnpressed then
                'Button is "Up" - Turn bold off
            Else
                 'Button is "down"  Turn bold on
        End If
If you set the MixedState property of a button to True, it always looks grayed outno matter what the value.
Allowing the User to Customize the Toolbar
One of the really great features of the ToolBar control is that you can allow your users to customize the toolbar to their liking. When the AllowCustomize property of the toolbar is set to True, users can access the Customize Toolbar dialog box by double-clicking the toolbar. This dialog box, shown in Figure 6.17, allows the user to add buttons to the toolbar, remove buttons, or move the buttons to a different location.
0135-01.jpg
Figure 6.17
The 
AllowCustomize property lets users customize the
toolbar to their liking, without the need for additional code.

 
< previous page page_135 next page >